<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>企业详细信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../css/main.css" media="all">
    <link rel="stylesheet" href="../../css/enterprisedetaildeinfo.css" media="all">
    <style>

    </style>
</head>
<body>

<!--主体内容-->
<div class="layui-fluid">
    <div class="layui-card-body" style="padding: 15px;">
        <form class="layui-form" action="" lay-filter="component-form-group" style="text-align: center">
            <div class="layui-form-item" style="padding-right: 125px">
                <div class="layui-inline">
                    <div id="changeimg" style="width: 140px;height: 140px">
                        <a id="uploadTX" href="javascript:;" class="chooseimg">更改</a>
                        <img src="../../image/defalut.jpg" id="uploadshow" class="layui-nav-img"
                             style="width: 100%;height: 100%">
                    </div>
                    <div style="height: 30px;text-align: center;margin-top: 20px">
                        <img id="attestationimg" src="../../image/icon_enterpriseWRZ.png"
                             style="width:25px;height: 80%">
                        <div id="attestationdiv" class="certified">
                            未认证
                        </div>
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-form-item" style="line-height: 60px">
                    </div>
                    <div class="layui-form-item" style="line-height: 60px">
                        <div class="layui-inline">
                            <label class="layui-form-label">企业名称</label>
                            <div class="layui-input-inline">
                                <input id="enterName" placeholder="" disabled class="layui-input"
                                       style="width: 500px;font-size: 18px">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item" style="line-height: 60px">
                        <div class="layui-inline">
                            <label class="layui-form-label">企业ID</label>
                            <div class="layui-input-inline">
                                <input id="enterID" placeholder="" disabled class="layui-input"
                                       style="width: 500px;font-size: 18px">
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div style="width: 100%;height:1.5px;border: #ff6000 0.1px solid"></div>
            <br>

            <!--  工商信息开始   -->
            <div id="business-info">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">电话号码</label>
                        <div class="layui-input-inline">
                            <input placeholder="公司电话" name="ephone" disabled class="layui-input imputset">
                        </div>
                    </div>

                    <div class="layui-inline" style="margin-left: 90px">
                        <label class="layui-form-label">企业邮箱</label>
                        <div class="layui-input-inline">
                            <input placeholder="企业邮箱" name="emailaccount" disabled class="layui-input imputset">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item" style="margin-left: 108px">
                    <div class="layui-inline">
                        <label class="layui-form-label">企业规模</label>
                        <div class="layui-input-inline">
                            <input placeholder="" name="scale" disabled class="layui-input imputset">
                        </div>
                    </div>

                    <div class="layui-inline" style="margin-left: 90px">
                        <label class="layui-form-label">行业</label>
                        <div class="layui-input-inline" style="width: 300px">
                            <input placeholder="" id="jobType" name="industry" disabled class="layui-input imputset">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">注册资本</label>
                        <div class="layui-input-inline">
                            <input placeholder="注册资本" name="registercapital" disabled
                                   class="layui-input imputset">
                        </div>
                    </div>

                    <div class="layui-inline" style="margin-left: 90px">
                        <label class="layui-form-label">工商注册号</label>
                        <div class="layui-input-inline">
                            <input placeholder="工商注册号" name="usccode" disabled class="layui-input imputset">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline" style="margin-left: 0px">
                        <label class="layui-form-label">企业类型</label>
                        <div class="layui-input-inline" style="width: 270px">
                            <input placeholder="" name="enterprisetype" disabled class="layui-input imputset">
                        </div>
                    </div>

                    <div class="layui-inline" style="margin-left: 10px">
                        <label class="layui-form-label">成立日期</label>
                        <div class="layui-input-inline">
                            <input type="text" name="date" id="date1" placeholder="成立日期" disabled
                                   class="layui-input imputset">
                        </div>
                    </div>

                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">组织机构代码</label>
                        <div class="layui-input-inline">
                            <input placeholder="组织机构代码" name="organizationcode" disabled class="layui-input imputset">
                        </div>
                    </div>

                    <div class="layui-inline" style="margin-left: 90px">
                        <label class="layui-form-label">社会信用代码</label>
                        <div class="layui-input-inline">
                            <input placeholder="社会信用代码" name="brncode" disabled class="layui-input imputset">
                        </div>
                    </div>
                </div>

                <!--                <div class="layui-form-item" style="margin-top: 50px">-->
                <!--                    <div class="layui-input-block">-->
                <!--                        <div class="layui-footer" style="left: 0">-->
                <!--                            <button class="layui-btn" style="background-color: #ff6000" lay-submit=""-->
                <!--                                    lay-filter="component-form-demo1">更改信息-->
                <!--                            </button>-->
                <!--                            <div style="height: 20px"></div>-->
                <!--                        </div>-->
                <!--                    </div>-->
                <!--                </div>-->
            </div>
            <!-- 工商信息结束   -->
            <div id="jumptoreg"></div>
        </form>

    </div>
</div>

<script src="../../libs/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['form', 'okLayer', 'element', 'layer', 'upload', 'laydate', 'jquery'], function () {
        let okLayer = layui.okLayer;
        let layer = layui.layer;
        let form = layui.form;
        let laydate = layui.laydate;
        let upload = layui.upload;
        let element = layui.element;
        let $ = layui.jquery;

        // 获取contentText
        const ctx = function () {
            let pathName = document.location.pathname;
            let index = pathName.substr(1).indexOf("/");
            let result = pathName.substr(0, index + 1);
            return result;
        }();

        // 获取enterprise
        var enterprise = JSON.parse(window.sessionStorage.getItem("enterprise"));
        //定时循环刷新状态
        freshstatus();
        //开启定时器，每五分钟请求一次最新数据
        var freshwork = setInterval(freshstatus, 300000);


        //定时循环刷新状态
        function freshstatus() {
            $.ajax({
                url: ctx + "/ygssecs/getenterByid",
                type: "GET",
                data: {priseid: enterprise.enterpriseid},
                dataType: "JSON"
            }).done(function (response) {
                if (response.code == 200) {
                    window.sessionStorage.setItem("enterprise", JSON.stringify(response.data));
                    var en = response.data;
                    if (en.certificationstatus == "0") {
                        $("#attestationimg").attr("src", "../../image/icon_enterpriseWRZ.png");
                        $("#attestationdiv").attr("class", "nocertified");
                        $("#attestationdiv").text("未认证");
                        $("#business-info").attr("class", "business-none");
                        $("#jumptoreg").attr("class", "business");
                        var nocheck = "你还未进行工商信息认证，认证之后才可发布岗位&nbsp;&nbsp;&nbsp;<a href='enterpriseAuth.html'" +
                            "style='color: #0e90d2'>快速认证</a>"
                        $("#jumptoreg").html(nocheck)
                    } else if (en.certificationstatus == "2") {
                        $("#attestationimg").attr("src", "../../image/icon_enterpriseYRZ.png");
                        $("#attestationdiv").attr("class", "certified");
                        $("#attestationdiv").text("已认证");
                        $("#business-info").attr("class", "business");
                        $("#jumptoreg").attr("class", "business-none");
                        clearInterval(freshwork);//停止定时器
                        laodinstry()//加载行业
                    } else if (en.certificationstatus == "1") {
                        $("#attestationimg").attr("src", "../../image/icon_enterpriseWRZ.png");
                        $("#attestationdiv").attr("class", "nocertified");
                        $("#attestationdiv").text("待审核");
                        $("#business-info").attr("class", "business-none");
                        $("#jumptoreg").attr("class", "business");
                        var checkhtml = "你已经提交认证信息，请耐心等待审核通过。"
                        $("#jumptoreg").html(checkhtml);
                    } else {
                        $("#attestationimg").attr("src", "../../image/icon_enterpriseWRZ.png");
                        $("#attestationdiv").attr("class", "nocertified");
                        $("#attestationdiv").text("待审核");
                        $("#business-info").attr("class", "business-none");
                        $("#jumptoreg").attr("class", "business");
                        var checkhtml = en.verificationremarks;
                        $("#jumptoreg").html(checkhtml);
                    }
                    $("#enterName").attr("placeholder", en.enterprisename);
                    $("#enterID").attr("placeholder", en.enterpriseid);
                } else if (response.code == 201) {//企业查询失败，重新登录
                    okLayer.yellowSighMsg(response.msg, function () {
                        parent.location.href = "enterpriseLogin.html";
                    });
                }
            }).fail(function () {
                parent.location.href = "enterpriseLogin.html";
            })
        }

        //加载行业数据
        function laodinstry() {

            //加载企业类型
            var loadIndex;
            $.ajax({
                url: ctx + "/ygssecs/getjobType",
                type: 'GET',
                dataType: 'JSON',
                beforeSend: function () {
                    loadIndex = layer.load(1, {shade: 0.3});
                }
                // headers: {"token": sessionStorage.getItem("token")},
            }).done(function (datas) {
                var list = datas['data'];
                var option;
                for (var i = 0; i < list.length; i++) {
                    option += "<option value='" + list[i]['typename'] + "'>" + list[i]['typename'] + "</option>";//拼接option中的内容
                }
                //将option的拼接内容加入select中，注意选择器是select的ID
                $("#jobType").append(option);
                form.render('select');//重点：重新渲染select
                layer.close(loadIndex);//移除加载遮罩
                loadauthinfo()
            }).fail(function () {
                console.log("error");
            });
        }

        //渲染工商认证信息
        function loadauthinfo() {
            $.ajax({
                url: ctx + "/ygssecs/getenterinfo",
                type: "GET",
                data: {enterpriseid: enterprise.enterpriseid},
                dataType: "JSON"
            }).done(function (response) {
                var edata = response.data;
                var laoddata = {
                    "registercapital": edata.registercapital,
                    "date": edata.originatetime,
                    "enterprisetype": edata.enterprisetype,
                    "usccode": edata.usccode,
                    "brncode": edata.brncode,
                    "organizationcode": edata.organizationcode,
                    "scale": edata.scale,
                    "industry": edata.industry,
                    "ephone": edata.enterprise.phonenumber || "暂无",
                    "emailaccount": edata.enterprise.emailaccount || "暂无"
                }
                form.val("component-form-group", laoddata);
            }).fail(function () {
                okLayer.redCrossMsg("数据加载失败");
            })
        }

        //日期
        laydate.render({
            elem: '#date1'
        });

        //单文件示例  选完文件后不自动上传
        var uploadSingle = upload.render({
            elem: '#uploadTX'
            , url: ctx + '/upload/TXImageUpload'
            , accept: 'images'  // 允许上传的文件类型
            , size: 2048        // 最大允许上传的文件大小  单位 KB
            , auto: true
            , bindAction: '#startUploadQR'
            , data: {diridentity: enterprise.enterpriseid}
            , choose: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#uploadshow').attr('src', result); //图片链接（base64）
                });
            }, done: function (res, index, upload) {
                if (res.code == 0) {
                    //上传成功
                    layer.open({
                        type: 0,
                        title: "修改成功",
                        icon: 1,
                        area: "300px",
                        content: "修改成功",
                        end: function () {
                            parent.location.reload();
                        }
                    });
                } else {
                    this.error(index, upload);
                }
            }, error: function (index, upload) {
                //演示失败状态，并实现重传
                var startDiv = $('#startDiv');
                startDiv.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload" style="width:50px;height:30px;text-align:center;line-height:30px;">重试</a>');
                startDiv.find('.demo-reload').on('click', function () {
                    uploadSingle.upload();
                });
            }
        });

        //加载logo
        if (enterprise.logoimg == null) {
            $("#uploadshow").attr('src', "../../image/defalut.jpg");
        } else {
            $("#uploadshow").attr('src', enterprise.logoimg);
        }

    });
</script>

</body>
</html>